% !TeX spellcheck = de_DE
\documentclass[UTF8,a4paper]{book} %设为A4纸
\usepackage{geometry}
\geometry{left=2cm,right=3cm,top=4cm,bottom=3cm} %设置页边距
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{verbatim}  %use verbatim
\usepackage{ctex}
\usepackage{ifthen}
\usepackage{makeidx}
\usepackage{graphicx}%缩放表格
\usepackage{xcolor}
\colorlet{lightcyan}{cyan!40!white}

%\usepackage{chngcntr}
\usepackage{stackengine}

\usepackage{tasks}

\newlength{\longestlabel}

\settowidth{\longestlabel}{\bfseries viii.}

\usepackage[lastexercise]{exercise}
%\counterwithin{Exercise}{chapter}
%\counterwithin{Answer}{chapter}

%\renewcounter{Exercise}[chapter]

\setlength{\QuestionIndent}{7em}

\usepackage{enumerate}

\newboolean{printanswer}

%---------------------答案格式开始定义-----------------------------------------
%判断题后面加括号
\newcommand{\pd}[2][1]{\nolinebreak\dotfill\mbox{\raisebox{-1.8pt}
		{$\cdots$}(\makebox[#1 cm][c]{
			\ifthenelse{\boolean{printanswer}}
			{\ifthenelse{\equal{#2}{t}}{\Checkmark}{\XSolid}}
			{}
		})}}


%填空题画线  \tk
%\newcommand{\tk}[2][2.5]{\; \underline{\hspace{#1 cm} \hphantom{#2} \hspace{#1 cm} } \, }
\usepackage{ulem}
\newcommand{\tk}[2][0.5]{\;\uline{ 
		\hspace*{#1 cm}
		\ifthenelse{\boolean{printanswer}}{#2}{\hphantom{#2}}  
		\hspace*{#1 cm}
} }
%简答题  \jd
\newcommand{\jd}[2][4]{\par
	%\begin{minipage}[t][#1cm][t]{0.92\linewidth}	
	\ifthenelse{\boolean{printanswer}}{
		\begin{Answer}
			答：\par
			#2
		\end{Answer}
	}
	{}  
	%\end{minipage} 
}	
%---------------------------答案格式结束定义---------------------------------
\usepackage[breaklinks,colorlinks,linkcolor=black,citecolor=black,urlcolor=black]{hyperref} %生成pdf中的书签
\setboolean{printanswer}{true} %控制是否输出习题的答案

\begin{document}
	
    \section{预备知识}
		\subsection{集合}
			\input{ex-settheory.tex}
		\subsection{关系}
			\input{ex-relation.tex}
		\subsection{函数}
			\input{ex-function.tex}
	\section{整除}
		\input{ex-ExactDivision.tex}
	\section{同余}
		\input{ex-congruence.tex}
	\section{二次剩余}
		\input{ex-QuadraResidue.tex}
	\section{原根与指数}
		\input{ex-PrimitiveRoot.tex}
	\section{课程编程练习}
		\input{ex-program.tex}
\end{document}